<?php

class SubscribeController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    	$request = $this->getRequest();
    	$form    = new Application_Form_FindByBarcode();
    	
    	if ($this->getRequest()->isPost()) {
    		if ($form->isValid($request->getPost())) {
    			if($barcode = $request->getParam('barcodeid')){
    				//$subscribe = new Application_Model_Subscribe($form->getValues());
    				//$barcode = 'CS2905785';
    				$mapper = new Application_Model_SubscribeMapper();
    				$this->view->entries = $mapper->findByBarcode($barcode);
    				//$this->view->entries = $mapper->fetchAll();
    			}
    			//
    			//
    			//$mapper->save($subscribe);
    			
    			//return $this->_helper->redirector('index');
    		}
    	}
    	
    	//$this->view->entries = $mapper->findByBarcode();
    	$this->view->form = $form;
    }

    public function findByBarcodeAction()
    {
        // action body
    	$request = $this->getRequest();
    	$form    = new Application_Form_FindByBarcode();
    	$mapper  = new Application_Model_SubscribeMapper();
    	
    	if ($this->getRequest()->isPost()) {
    		if ($form->isValid($request->getPost())) {
    			if($barcode = $request->getParam('barcodeid')){
    				$this->view->entries = $mapper->findByBarcode($barcode);
    			}
    			//$subscribe = new Application_Model_Subscribe($form->getValues());
    			//$mapper  = new Application_Model_SubscribeMapper();
    			//$mapper->save($subscribe);
    			
    			//return $this->_helper->redirector('index');
    		}
    	}
    	
    	//$this->view->entries = $mapper->findByBarcode();
    	$this->view->form = $form;
    }

    public function dumpAction()
    {
        // action body
    	$sub = new Application_Model_SubscribeMapper();
    	$this->view->entries = $sub->fetchAll();
    }

    public function sendAction()
    {
        // action body
        
    }


}







